<?php defined('SYSPATH') or die('No direct script access.');
 
class Model_Avideo extends ORM {
	protected $_table_name = 'video';

    public function params() {
        return array(
        	'model' => 'Avideo',
            'table' => 'video',
            'fields' => array(
                'category_id' => array(
                    'title' => 'Категория',
                    'name' => 'category_id',
                    'type' => 'relation',
                    'relation_params' => array(
                        'type' => 'BELONGS_TO',
                        'model' => 'Avideocat',
                        'field' => 'title'
                    ),
                ),
                'description' => array(
                    'title' => 'Описание',
                    'type' => 'textarea',
                    'name' => 'description',
                ),
                'video' => array(
                    'title' => 'Код видео',
                    'type' => 'textarea',
                    'name' => 'video',
                ),
                'image' => array(
                    'title' => 'Превью',
                    'type' => 'image',
                    'name' => 'image',
                    'image_params' => array(
                        'width' => 210,
                        'height' => 160,
                        'handling' => 'resize_crop',
                        'resize_type' => Image::AUTO,
                        'dir' => $_SERVER['DOCUMENT_ROOT'].'/static/uploads/video',
                        'url' => URL::base().'static/uploads/video',
                    ),
                    'thumbnails' => array(
                        'admin' => array(
                            'width' => 300,
                            'height' => 200,
                            'handling' => 'resize_crop',
                            'resize_type' => Image::AUTO,
                        ),
                    ),
                ),
                'display' => array(
                    'title' => 'Показывать?',
                    'type' => 'checkbox',
                    'name' => 'display',
                ),
            ),
            'search_indexes' => array(
                array('field' => 'description', 'title' => 'Описание'),
            ),
            'main_title' => 'Видео',
            'waymark' => 'description',
        );
    }

}